package com.tieto.user.bean;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;

import lombok.Data;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import com.tieto.user.service.UserManagement;

@ManagedBean(name="loginBean")
@RequestScoped
@Data
public class LoginBean {
	private static final Logger LOG = LogManager.getLogger(LoginBean.class);
	private String username;
	private String password;
	@ManagedProperty(value="#{userManagement}")
	@Autowired
	private UserManagement userManagement;

	public String login() {
		LOG.debug("login");
		if (userManagement.findOne(username) != null) {
			return "success";
		} else {
			return null;
		}
	}
}
